package com.example.service.impl;

import com.example.manager.ProductManager;
import com.example.model.ProductDO;
import com.example.mapper.ProductMapper;
import com.example.service.ProductService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.vo.ProductVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yinxin
 * @since 2022-06-13
 */
@Service
public class ProductServiceImpl implements ProductService {

    @Autowired
    ProductManager productManager;

    @Override
    public List<ProductVO> list() {
        return productManager.list();
    }

    @Override
    public ProductVO findDetailById(Long id) {
        ProductDO productDO = productManager.findDetailById(id);
        return beanProcess(productDO);
    }

    private ProductVO beanProcess(ProductDO productDO){
        ProductVO productVO = new ProductVO();
        BeanUtils.copyProperties(productDO,productVO);
        return productVO;
    }
}
